<template>
  <div>
    <Table border :columns="columns7" :data="data6"></Table>
    <button @click="deleteArray">删除什么</button>
  </div>
</template>
<script>
    export default {
        data () {
            return {
                total2: '',

                columns7: [
                    {
                        title: 'Name',
                        key: 'name',
                        render: (h, params) => {
                            return h('div', [
                                h('Icon', {
                                    props: {
                                        type: 'person'
                                    }
                                }),
                                h('strong', params.row.name)
                            ]);
                        }
                    },
                    {
                        title: 'Age',
                        key: 'age'
                    },
                    {
                        title: 'Address',
                        key: 'address'
                    },
                    {
                        title: 'Action',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h(
                                    'Button',
                                    {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            marginRight: '5px'
                                        },
                                        on: {
                                            click: () => {
                                                this.show(params.index);
                                            }
                                        }
                                    },
                                    'View'
                                ),
                                h(
                                    'Button',
                                    {
                                        props: {
                                            type: 'error',
                                            size: 'small'
                                        },
                                        ref: 'delete',
                                        on: {
                                            click: () => {
                                                console.log(params);
                                                this.getSummary(params);
                                            }
                                        }
                                    },
                                    `Delete:${this.getSummary(params)}`
                                )
                            ]);
                        }
                    }
                ],
                data6: []
            };
        },
        methods: {
            show (index) {
                this.$Modal.info({
                    title: 'User Info',
                    content: `Name：${this.data6[index].name}<br>Age：${
                        this.data6[index].age
                    }<br>Address：${this.data6[index].address}`
                });
            },
            remove (index) {
                this.data6.splice(index, 1);
            },
            getSummary (params) {
                let array = Object.values(params.row);
                array.splice(array.length - 2, 2);
                console.log(array);
                let total = array.reduce(function (prev, cur) {
                    return prev + cur;
                }, 0);

                this.total2 = total;
                return total;
            },
            deleteArray () {
                this.columns7.shift();
                this.data6.shift();
                this.data6.map(item => {
                    item.age = item.age + 1;
                });
                console.log(this.data6);
            }
        }
    };
</script>
